﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chap5 {
    class ConstructorChaining {
        public int driverIntensity;
        public string driverName;


        private int test;

        public int Test {
            get { return test; }
            set { test = value; }
        }

        public ConstructorChaining() {
            Console.WriteLine("default constructor");
        }

        public ConstructorChaining(int intensity) : this(intensity, "") {
            Console.WriteLine("in constructor taking int ");
        }

        public ConstructorChaining(string name) : this(0, name) {
            Console.WriteLine("in constructor taking string");
        }

        /// <summary>
        /// This is the 'master' constructor that does all the real work.
        /// </summary>
        /// <param name="intensity"></param>
        /// <param name="name"></param>
        public ConstructorChaining(int intensity, string name) {
            Console.WriteLine("master constructor");
            if (intensity > 10) {
                intensity = 10;
            }
            driverIntensity = intensity;
            driverName = name;
        }

        public void SetIntensity(int intensity) {
            if (intensity > 10) {
                intensity = 10;
            }
            driverIntensity = intensity;
        }

        public void SetDriverName(string name) {
            // These two statements are functionally the same.
            driverName = name;
            this.driverName = name;
        }

        public void PopAWheely() {
            for (int i = 0; i <= driverIntensity; i++) {
                Console.WriteLine("Yeeeeeee Haaaaaeewww!");
            }
        }
    }
}